home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tptsr.zip / TSR.SKL < prev    next >
Text File  |  1990-06-25  |  4KB  |  144 lines

  1. program Skeleton;   { Use this code to cookbook your TSR program. }
  2.  
  3.  
  4. { You must define four procedures that are passed as parameters to }
  5. { MakeTSR().  I have named them here as: Startup, Popup, Wrapup, and }
  6. { OptionComm to suggest their functionality but you can name them }
  7. { any names you want.  The procedure headers must, however, match }
  8. { the procedure type parameters in MakeTSR(), see tsr.int. }
  9.  
  10.  
  11. uses crt, tsr, cmdln;
  12.  
  13. {$M 0,0,0}   { Set to the minimum size tolerable to your program }
  14.  
  15.  
  16. {$F+}
  17. procedure Startup;              { Called when TSR installed. }
  18.     var params : CmdLnParams;
  19.     begin
  20.  
  21. { The following code explains the tsr unit command line switches. }
  22.  
  23.         clrscr;
  24.         writeln('Skeleton TSR');
  25.         writeln;
  26.         writeln('Press <Alt> P to popup.');
  27.         writeln;
  28.         writeln('At the command line prompt type: ');
  29.         writeln;
  30.         writeln('   Skeleton -r       to remove the TSR from memory,');
  31.         writeln('   Skeleton -d       to deactivate the TSR in memory,');
  32.         writeln('   Skeleton -a       to activate TSR in memory,');
  33.         writeln('   Skeleton -m       to force monochrome display,');
  34.         writeln('   Skeleton -c       to force color display,');
  35.         writeln('   Skeleton -kcode   code is scan code of hotkey,');
  36.         writeln('   Skeleton -sshift  shift is shift state of hotkey,');
  37.         writeln('   Skeleton -p       to popup TSR.');
  38.         writeln;
  39.         writeln('Run hotkey.exe to determine code and shift.');
  40.  
  41. { Add any additional options instructions here. }
  42. { Additional options are specified in the call to MakeTSR() below. }
  43. { Options issued while installing should be processed here. }
  44. { Options communicated to resident TSR are processed by OptionComm below. }
  45. { Psuedo code is presented below for adding "q" as an option.  }
  46. { See cmdln.doc for details. }
  47.  
  48.         writeln('   Skeleton -q     an option for your application');
  49. { Use tsr.TSRandPopupOptions to specify options to CmdLnParams object. }
  50.         params.init(TSRandPopupOptions);
  51.         while (params.getOption <> #0) do begin
  52.             case params.optCh of
  53.                     'r','R': ; { Processed by TSR unit. }
  54.                     'a','A': ; { Processed by TSR unit. }
  55.                     'd','D': ; { Processed by TSR unit. }
  56.                     'm','M': ; { Processed by TSR unit. }
  57.                     'c','C': ; { Processed by TSR unit. }
  58.                     'H','h': ; { Processed by TSR unit. }
  59.                     'p','P': ; { Processed by TSR unit. }
  60.                     '?':     ; { Processed by TSR unit. }
  61.                     'q','Q': ; { Your application processes this one! }
  62.                 end;
  63.             while (params.paramNo <= ParamCount) do begin
  64.                 writeln('Argument: ',ParamStr(params.paramNo));
  65.                 { Your application should process arguments here. }
  66.                 inc(params.paramNo)
  67.                 end
  68.             end;
  69.  
  70. { Any initialization code for your program belongs here. }
  71.  
  72.     end;
  73. {$F-}
  74.  
  75.  
  76.  
  77. {$F+}
  78. procedure Popup;           { Called when hotkey pressed. }
  79.     begin
  80.  
  81. { Place the code you want executed when the hotkey is pressed here. }
  82.  
  83.     { If your TSR is not prepared to popup in graphic modes then don't! }
  84.         if not CrtPlus.TxtScr.IsTextMode then
  85.            exit;
  86.     { Use tsr.TSRcolor to determine color or monochrome operation, e.g. }
  87.         if TSRcolor then begin
  88.             TextColor(BLACK);
  89.             TextBackground(CYAN)
  90.             end
  91.         else begin
  92.             TextColor(BLACK);
  93.             TextBackground(LIGHTGRAY)
  94.             end;
  95.  
  96.  
  97.     end;
  98. {$F-}
  99.  
  100.  
  101.  
  102. {$F+}
  103. procedure Wrapup;          { Called when TSR removed from memory. }
  104.     begin
  105.  
  106. { Any cleanup code you want executed when the TSR is removed belongs here. }
  107.  
  108.     end;
  109. {$F-}
  110.  
  111.  
  112.  
  113. {$F+}
  114. procedure OptionComm(optCh: char; argSeg, argOfs : word);  { See notes below. }
  115.     var StrPtr : ^string;
  116.     begin
  117.         if optCh <> #0 then
  118.             write('Option: ',optCh,'    ');
  119.         StrPtr := Ptr(argSeg, argOfs);
  120.         if length(StrPtr^) > 0 then
  121.             write('argument: ',StrPtr^);
  122.         writeln;
  123.  
  124. { Once resident, invoking your TSR with command line switches or arguments }
  125. { results in a call to this procedure.  The code above demonstrates how to }
  126. { recover that information.  See cmdln.doc for further information on }
  127. { specifying options.  The additional options are specified in the call to }
  128. { MakeTSR() below. }
  129.  
  130.     end;
  131. {$F-}
  132.  
  133.  
  134.  
  135. begin
  136.  
  137. { Additional options belong in first parameter: see cmdln.doc }
  138.  
  139.     MakeTSR('q','Skeleton',25,8,Startup,Popup,Wrapup,OptionComm);
  140.  
  141. { 25 and 8 are the scan code and shift state for <alt> P. }
  142. { Run hotkey.exe to find code and state for your hotkey choice. }
  143.  
  144. end.